<template>
  <div class="teacher-detail-container">
    <!-- 顶部信息 -->
    <div class="header">
      <div class="back-btn" @click="router.back()">
        <span class="icon">←</span> 返回教师列表
      </div>
      <div class="teacher-info">
        <div class="avatar">👨‍🏫</div>
        <div class="info">
          <h1>{{ teacherInfo.name }}</h1>
          <p>{{ teacherInfo.title }} | {{ teacherInfo.department }}</p>
        </div>
      </div>
    </div>

    <!-- 统计卡片 -->
    <div class="stat-cards">
      <div v-for="stat in stats" :key="stat.id" class="stat-card">
        <div class="stat-icon" :style="{ background: stat.color }">{{ stat.icon }}</div>
        <div class="stat-info">
          <h3>{{ stat.title }}</h3>
          <div class="stat-value">{{ stat.value }}</div>
        </div>
      </div>
    </div>

    <!-- 课程列表 -->
    <div class="courses-section">
      <h2>授课课程</h2>
      <div class="course-grid">
        <div v-for="course in courses" :key="course.id" 
             class="course-card"
             @click="goToCourseDetail(course.id)">
          <div class="course-icon">📚</div>
          <div class="course-info">
            <h3>{{ course.name }}</h3>
            <p>{{ course.time }}</p>
          </div>
          <div class="course-stats">
            <div class="stat">
              <span class="label">班级数</span>
              <span class="value">{{ course.classCount }}</span>
            </div>
            <div class="stat">
              <span class="label">学生数</span>
              <span class="value">{{ course.studentCount }}</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'

const route = useRoute()
const router = useRouter()

// 教师基本信息
const teacherInfo = ref({
  name: 'XXX1',
  title: '教授',
  department: '软件工程系'
})

// 统计数据
const stats = ref([
  {
    id: 1,
    title: '授课班级',
    value: '5个',
    icon: '👥',
    color: '#1890ff'
  },
  {
    id: 2,
    title: '授课课程',
    value: '3门',
    icon: '📚',
    color: '#52c41a'
  },
  {
    id: 3,
    title: '学生总数',
    value: '150人',
    icon: '👨‍🎓',
    color: '#722ed1'
  },
  {
    id: 4,
    title: '平均分',
    value: '85.6',
    icon: '📊',
    color: '#faad14'
  }
])

// 课程数据
const courses = ref([
  {
    id: 1,
    name: '数据结构',
    time: '周一 1-2节',
    classCount: 2,
    studentCount: 60
  },
  {
    id: 2,
    name: '算法分析',
    time: '周三 3-4节',
    classCount: 1,
    studentCount: 45
  },
  {
    id: 3,
    name: '计算机网络',
    time: '周五 5-6节',
    classCount: 2,
    studentCount: 45
  }
])

// 跳转到课程详情
const goToCourseDetail = (courseId) => {
  router.push(`/admin/teacher/${route.params.teacherId}/course/${courseId}`)
}
</script>

<style scoped>
.teacher-detail-container {
  padding: 30px;
  background: #f0f2f5;
  min-height: 100vh;
}

.header {
  display: flex;
  align-items: center;
  gap: 30px;
  margin-bottom: 30px;
}

.back-btn {
  padding: 10px 20px;
  background: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.teacher-info {
  display: flex;
  align-items: center;
  gap: 20px;
}

.avatar {
  font-size: 48px;
  background: white;
  width: 80px;
  height: 80px;
  border-radius: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.courses-section {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.course-card {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.course-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.course-icon {
  font-size: 24px;
  margin-bottom: 12px;
}

.course-info h3 {
  margin: 0;
  font-size: 18px;
}

.course-info p {
  margin: 4px 0;
  color: #666;
}

.course-stats {
  display: flex;
  justify-content: space-around;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #eee;
}

.stat {
  text-align: center;
}

.stat .label {
  display: block;
  font-size: 12px;
  color: #666;
}

.stat .value {
  display: block;
  font-size: 16px;
  font-weight: 500;
  color: #1890ff;
}
</style> 